package com.helloandroid.dialogs

import android.content.Context
import com.helloandroid.AppUtil
import com.helloandroid.MyApplication
import com.helloandroid.R
import com.helloandroid.base.BaseDialog
import com.tencent.mm.opensdk.modelmsg.SendAuth

class BindWxTipDialog(ctx:Context) : BaseDialog(ctx) {

    override fun getContentViewResId(): Int  = R.layout.dialog_bindwx_tip

    override fun initView() {
        findBtn(R.id.btnClose).setOnClickListener{
            cancel()
        }

        findBtn(R.id.btnBind).setOnClickListener {
            // 进行绑定
            bindWx()
            cancel()
        }
    }

    override fun initData() {
    }

    private fun bindWx(){
        if (!AppUtil.wxApi.isWXAppInstalled){
            AppUtil.toast("您还未安装微信客户端!")
            return
        }
        val seq = SendAuth.Req()
        seq.scope = "snsapi_userinfo"
        seq.state = "ttjb_wx_login"
        AppUtil.wxApi.sendReq(seq)
    }
}